/**
 * 
 */ 
package com.laozhao.test.action; 

import java.util.ArrayList;

/** 
 * @author dozhao 
 * @version create time：Jul 29, 2011 3:17:36 PM 
 * 
 */
/**
 * @author dozhao
 *
 */
public class MySource {

	private ArrayList<Listenable> listens;
	public MySource(){
		listens = new ArrayList<Listenable>();
	}
	public void addListener(Listenable listenable) {
		listens.add(listenable);
		
	}

	public void setValue(int i) {
		MyEvent e;
		for (int j = 0; j < listens.size(); j++) {
			Listenable listenable = listens.get(j);
			e = new MyEvent();
			e.setValue(i);
			listenable.enventChanged(e);
		}
	}
	
	public static void main(String args[]) {
		MySource ms = new MySource();
		MyListener ml = new MyListener();
		ms.addListener(new Listenable() {

			public void enventChanged(MyEvent e) {
				System.out.println("print 1");
			}
		});
		ms.addListener(ml);
		ms.setValue(10);
	}
}
 